package com.app.GoCuro;

import java.util.ArrayList;

import com.app.GoCuro.data.CurrentSession;
import com.app.GoCuro.data.DatabaseItem;
import com.app.GoCuro.data.JobsiteInformation;
import com.app.GoCuro.data.LoginResponse;
import com.app.GoCuro.util.CustomHttpClient;


import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ViewItemsActivity extends BaseActivity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.view_items);
	    
	    final ListView itemList = (ListView) findViewById(R.id.database_items);
	    
	    CustomHttpClient client = new CustomHttpClient(this);
	    CurrentSession currSession = (CurrentSession) getApplicationContext();
	    
	    ArrayList<DatabaseItem> databaseItems = client.getDatabaseItems(
	    		currSession.getLogin().getUserName(), currSession.getLogin().getPwd(), currSession.getJobsite().getId());
	    
	    //do not setup the items if the databases are null
	    if (databaseItems == null) return;
	    
	    ArrayAdapter<DatabaseItem> adapter = new ArrayAdapter<DatabaseItem>(this, android.R.layout.simple_list_item_1, databaseItems);
	    itemList.setAdapter(adapter);
	    
	    // TODO Auto-generated method stub
	}

}
